﻿<?xml version="1.0" encoding="utf-8" ?>
<AdoNetDataAccess connection="$SyrinxDBConnection$" formatter="bizobjlist of Article">
<FormatterInfo>
    <code for="vars" on="Article">
    bool stripLeading = true;
    bool setup = false;
  </code>
  <code for="postEach" on="Article">
    <![CDATA[
			try
			{
        if(!setup)
        {
          if(info.get("stripLeading") is bool)
            stripLeading = (bool)info.get("stripLeading");
          else if(info.get("stripLeading") is string)
            stripLeading = (string.Compare((string)info.get("stripLeading"), "False", true) == 0)?false:true;
          setup = true;
        }
          
        if(stripLeading)
        {
          string title = (string)CurrentBizObj.get("baseTitle");
          int titIndex = title.IndexOf("~!");
          if(titIndex != -1)
            CurrentBizObj.put("baseTitle", title.Substring(titIndex+2));
        }
			}
			catch(Exception e)
			{
			}
		]]>
  </code>
</FormatterInfo>
    <Sql>
		SELECT DISTINCT 
			t1.id, a.baseTitle, c.depth, c.keyName, t2.parentHostId, a.readMoreJump
		<code>
			if(Cmn.IsTrue(info.get("includeTranslations")))
			sql.Append(",a.translatedTitles");
		</code>
		FROM            
			ObjectTreeNodes AS t2
		LEFT OUTER JOIN	ObjectTreeNodes AS t1 ON t2.parentHostId = t1.id
		LEFT OUTER JOIN ObjectTreeCounts AS c on c.objectId = t1.objectId
		LEFT OUTER JOIN Articles as a on t1.id = a.id
			
		WHERE
			(t2.objectId = @id)
		ORDER BY 
			c.depth <code><![CDATA[sql.Append(info.get("dir"));]]></code>
	</Sql>
	<Param name="id" type="UniqueIdentifier"/>
</AdoNetDataAccess>